package com.shengzai.mapreduce.groupby2;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/*
    自定义排序类按班级，成绩进行排序
 */
public class MapOrder extends Mapper<LongWritable, Text,Text,Text> {

    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, Text>.Context context) throws IOException, InterruptedException {
        String[] split = value.toString().split("\t");
        String[] info = split[1].split(",");
        String clazz = info[3];
        //1500100007	尚孤风,23,女,文科六班,418
        //Sid   name    sex     score
        String values = split[0] + "," + info[0] + "," + info[2] + "," + info[4];
        context.write(new Text(clazz),new Text(values));
    }
}
